% function drawer = drawimage(data,U,L,magnification,heading)
% function drawer = drawimage(data,U,L,magnification,heading,descp)
function b = gencolorbar(data)

x=65;
imagedata = zeros(size(data));
sizedata = size(data);
row = sizedata(1,1);
col = sizedata(1,2);
for(i=1:1:row)
    for(j=1:1:col)
%----------------------------------------------------------------------        
    if(data(i,j)<0)
        imagedata(i,j,1)=0;
        imagedata(i,j,2)=0;                                 %ZONE 1
        imagedata(i,j,3)=0;
%----------------------------------------------------------------------                
    elseif(data(i,j)<=6.25 & data(i,j)>0)
        imagedata(i,j,1)=0;
        imagedata(i,j,2)=0;    %ZONE 2
        imagedata(i,j,3)=0;
%----------------------------------------------------------------------                
    elseif(data(i,j)<=12.5 & data(i,j)>6.25)
        imagedata(i,j,1)=x;
        imagedata(i,j,2)=0;    %ZONE 3
        imagedata(i,j,3)=2*x;
%----------------------------------------------------------------------
    elseif(data(i,j)<=18.75 & data(i,j)>12.5)
        imagedata(i,j,1)=x;
        imagedata(i,j,2)=0;    %ZONE 4
        imagedata(i,j,3)=3*x;
%----------------------------------------------------------------------                
    elseif(data(i,j)<=25 & data(i,j)>18.75)
        imagedata(i,j,1)=0;
        imagedata(i,j,2)=0;    %ZONE 5
        imagedata(i,j,3)=4*x;
%----------------------------------------------------------------------                
    elseif(data(i,j)<=31.25 & data(i,j)>25)
        imagedata(i,j,1)=0;
        imagedata(i,j,2)=2*x;    %ZONE 6
        imagedata(i,j,3)=4*x;
%----------------------------------------------------------------------                
    elseif(data(i,j)<=37.5 & data(i,j)>31.25)
        imagedata(i,j,1)=0;
        imagedata(i,j,2)=3*x;    %ZONE 7
        imagedata(i,j,3)=4*x;
%----------------------------------------------------------------------                
    elseif(data(i,j)<=43.75 & data(i,j)>37.5)
        imagedata(i,j,1)=0;
        imagedata(i,j,2)=4*x;    %ZONE 8
        imagedata(i,j,3)=4*x;
%----------------------------------------------------------------------                
    elseif(data(i,j)<=50 & data(i,j)>43.75)
        imagedata(i,j,1)=0;
        imagedata(i,j,2)=4*x;    %ZONE 9
        imagedata(i,j,3)=2*x;
%----------------------------------------------------------------------                
            elseif(data(i,j)<=56.25 & data(i,j)>50)
        imagedata(i,j,1)=0;
        imagedata(i,j,2)=4*x;    %ZONE 10
        imagedata(i,j,3)=0;
%----------------------------------------------------------------------                
            elseif(data(i,j)<=62.5 & data(i,j)>56.25)
        imagedata(i,j,1)=2*x;
        imagedata(i,j,2)=4*x;    %ZONE 11
        imagedata(i,j,3)=0;
%----------------------------------------------------------------------                
            elseif(data(i,j)<=68.75 & data(i,j)>62.5)
        imagedata(i,j,1)=3*x;
        imagedata(i,j,2)=4*x;    %ZONE 12
        imagedata(i,j,3)=0;
%----------------------------------------------------------------------                
            elseif(data(i,j)<=75 & data(i,j)>68.75)
        imagedata(i,j,1)=4*x;
        imagedata(i,j,2)=4*x;    %ZONE 13
        imagedata(i,j,3)=0;
%----------------------------------------------------------------------                
            elseif(data(i,j)<=81.25 & data(i,j)>75)
        imagedata(i,j,1)=4*x;
        imagedata(i,j,2)=3*x;    %ZONE 14
        imagedata(i,j,3)=0;
%----------------------------------------------------------------------                
            elseif(data(i,j)<=87.5 & data(i,j)>81.25)
        imagedata(i,j,1)=4*x;
        imagedata(i,j,2)=2*x;    %ZONE 15
        imagedata(i,j,3)=0;
%----------------------------------------------------------------------                
            elseif(data(i,j)<=93.75 & data(i,j)>87.5)
        imagedata(i,j,1)=4*x;
        imagedata(i,j,2)=x;    %ZONE 16
        imagedata(i,j,3)=0;
%----------------------------------------------------------------------                
            elseif(data(i,j)<=100 & data(i,j)>93.75)
        imagedata(i,j,1)=4*x;
        imagedata(i,j,2)=0;    %ZONE 17
        imagedata(i,j,3)=0;
%----------------------------------------------------------------------                      
            elseif(data(i,j)>100)
        imagedata(i,j,1)=4*x;
        imagedata(i,j,2)=0;    %ZONE 18
        imagedata(i,j,3)=0;
    end
    end
end
%----------------------------------------------------------------------   
imagedata1=flip_x(imagedata(:,:,1));
imagedata2=flip_x(imagedata(:,:,2));
imagedata3=flip_x(imagedata(:,:,3));
imagedata(:,:,1)=imagedata1;
imagedata(:,:,2)=imagedata2;
imagedata(:,:,3)=imagedata3;
imagedata = uint8(imagedata);
% save imagedata;
b=[imagedata(:,1,1),imagedata(:,1,2),imagedata(:,1,3)];
b=double(b);
b=b/255;
% rgb = [0:1/256:1;0:1/256:1;0:1/256:1]';
% % colormap(rgb);
% bigfuzz = imresize(imagedata,magnification,'bilinear');
% % bigfuzz2 = imresize(imagedata,magnification,'nearest');
% 
% % newbigfuzz(:,:,1)=(bigfuzz1(:,:,1)+bigfuzz2(:,:,1))/2;
% % newbigfuzz(:,:,2)=(bigfuzz1(:,:,2)+bigfuzz2(:,:,2))/2;
% % newbigfuzz(:,:,3)=(bigfuzz1(:,:,3)+bigfuzz2(:,:,3))/2;
% 
% rgb = [0:1/256:1;0:1/256:1;0:1/256:1]';
% colormap(rgb);
% % t=flip_x(bigfuzz);
% % iptsetpref('ImshowAxesVisible');
% % imshow(bigfuzz);
% % x=[0 5];
% % y=[0 9];
% % imshow(x,y,bigfuzz);
% image(bigfuzz);
% colormap(b);
% h=colorbar('vert');
% % imshow(newbigfuzz);
% title(stringw);
% % image(imagedata);
% title(heading);
% text(uint8(size(bigfuzz,2)/2),size(bigfuzz,1)+15,descp,'FontSize',7,'Hori
% zontalAlignment','right');
% text(340,size(bigfuzz,1)+15,descp,'FontSize',7,'HorizontalAlignment','right');



%Note:- Never use small L in Matlab.